#ifndef _PG_FILE_H_
#define _PG_FILE_H_

#include"IFile.h"
#include"IObject.h"

class PALEGEM_API pgFile : public IFile
{
public:

	// IFile
	pgFile();
	~pgFile();
	virtual bool CreateFile(const char* sFilename);
	bool OpenFile(const char* sFilename, bool bCreateNew = false);
	bool DeleteFile(bool bKeepTextBuffer = false);
	FILE* GetFilePointer()	{return m_pFile;}
	std::string GetTextBuffer() {return m_sTextBuffer;}
	size_t FindString(const char* sString, ...);
	void Append(const char* sString, ...);
	void PushFront(const char* sString, ...);
	bool EraseFromFile(const char* sString, size_t pos = -1);
	bool Insert( size_t pos, const char* sString, ...);
	bool Write(size_t pos, const char* sString, ...);
	bool ReplaceString(const char* sToReplace, const char* sReplacement, size_t pos = 0);	


	// TODO
	// Implement Find(size_t pos, const char* sString, ...)
	// Implement GetString(size_t begin, size_t end);

protected:
	bool Flush();

	FILE			*m_pFile;
	std::string		m_sTextBuffer;
	bool			m_bIsFileCreated;
	bool			m_bIsFileOpened;
	std::string		m_sFilename;
};

#endif